/*
 * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available.
 *
 * Copyright (C) 2022 THL A29 Limited, a Tencent company.  All rights reserved.
 *
 * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license.
 *
 * A copy of the MIT License is included in this file.
 *
 *
 * Terms of the MIT License:
 * ---------------------------------------------------
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
 * the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
 * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package com.tencent.bkrepo.common.analysis.pojo.scanner.trivy

import com.fasterxml.jackson.annotation.JsonAlias
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

@ApiModel("漏洞信息")
data class VulnerabilityItem(
    @ApiModelProperty("漏洞编号")
    @JsonAlias("VulnerabilityID")
    val vulnerabilityId: String,
    @ApiModelProperty("PkgName")
    @JsonAlias("PkgName")
    val pkgName: String = "",
    @ApiModelProperty("安装版本")
    @JsonAlias("InstalledVersion")
    val installedVersion: String = "",
    @ApiModelProperty("修复版本")
    @JsonAlias("FixedVersion")
    val fixedVersion: String = "",
    @ApiModelProperty("Layer")
    @JsonAlias("Layer")
    val layer: Layer? = null,
    @ApiModelProperty("严重来源")
    @JsonAlias("SeveritySource")
    val severitySource: String = "",
    @ApiModelProperty("PrimaryURL")
    @JsonAlias("PrimaryURL")
    val primaryUrl: String = "",
    @ApiModelProperty("PkgName")
    @JsonAlias("DataSource")
    val dataSource: DataSource? = null,
    @ApiModelProperty("Title")
    @JsonAlias("Title")
    val title: String = "",
    @ApiModelProperty("Description")
    @JsonAlias("Description")
    val description: String = "",
    @ApiModelProperty("Severity")
    @JsonAlias("Severity")
    var severity: String = "",
    @ApiModelProperty("CweIDs")
    @JsonAlias("CweIDs")
    val cweIds: List<String>? = null,
    @ApiModelProperty("CVSS")
    @JsonAlias("CVSS")
    val cvss: Map<String, CVSS>? = null,
    @ApiModelProperty("References")
    @JsonAlias("References")
    val references: List<String>? = null,
    @ApiModelProperty("PublishedDate")
    @JsonAlias("PublishedDate")
    val publishedDate: String = "",
    @ApiModelProperty("LastModifiedDate")
    @JsonAlias("LastModifiedDate")
    val lastModifiedDate: String = ""
) {
    companion object {
        const val TYPE = "VULNERABILITY_ITEM"
    }
}

@ApiModel("Layer")
data class Layer(
    @ApiModelProperty("Digest")
    @JsonAlias("Digest")
    val digest: String = "",
    @ApiModelProperty("DiffID")
    @JsonAlias("DiffID")
    val diffId: String = ""
)

@ApiModel("DataSource")
data class DataSource(
    @ApiModelProperty("ID")
    @JsonAlias("ID")
    val id: String = "",
    @ApiModelProperty("Name")
    @JsonAlias("Name")
    val name: String = "",
    @ApiModelProperty("URL")
    @JsonAlias("URL")
    val url: String = ""
)

@ApiModel("CVSS")
data class CVSS(
    @ApiModelProperty("V2Vector")
    @JsonAlias("V2Vector")
    val v2Vector: String = "",
    @ApiModelProperty("V3Vector")
    @JsonAlias("V3Vector")
    val v3Vector: String = "",
    @ApiModelProperty("V2Score")
    @JsonAlias("V2Score")
    val v2Score: String = "",
    @ApiModelProperty("V3Score")
    @JsonAlias("V3Score")
    val v3Score: String = ""
)
